package ui;

import java.awt.Color;
import java.awt.Component;
import java.awt.SystemColor;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

@SuppressWarnings("serial")
public class ObjetoRender extends DefaultTableCellRenderer {

	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, 
			boolean hasFocus, int row, int column) {
			
		JLabel cell = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, false, 
				row, column);

		cell.setForeground(Color.black);
		
		if(row%2 == 0) {
			cell.setBackground(SystemColor.window);
		}
		else
			cell.setBackground(SystemColor.control);
		
		if(isSelected) {
			cell.setBackground(SystemColor.scrollbar);				
		}
		
		switch(column) {
			case 0:
				cell.setHorizontalAlignment(SwingConstants.CENTER);
				break;
			case 1:
				cell.setHorizontalAlignment(SwingConstants.LEFT);
				break;
			case 2:
				cell.setHorizontalAlignment(SwingConstants.RIGHT);
				break;
		}
		
		return cell;
	}
}